import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {RepairRequest} from '../../types/resp/RepairRequest';

@Component({
  selector: 'repair-request-view',
  imports: [
    SharedModule
  ],
  templateUrl: './repair-request-view.component.html',
  standalone: true
})
export class RepairRequestViewComponent implements OnInit {
  repairRequestForm!: FormGroup;
  isVisible: boolean = false
  title: string = '报修信息详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.repairRequestForm = this.fb.group({
      buildingName: [''],
      roomNumber: [''],
      description: [''],
      requestTime: [''],
      status: [undefined],
      staffName: [''],
      remark: [''],
      finishTime: [''],
      createTime: [''],
      modifyTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(repairRequest: RepairRequest) {
    this.isVisible = true
    this.repairRequestForm.patchValue(repairRequest);
    this.repairRequestForm.disable();
  }
}
